home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Graphics / SMan / WarpOS / Source / ULP6.asm < prev    next >
Encoding:
Assembly Source File  |  2001-03-26  |  3.5 KB  |  141 lines

  1. #Most comments from ULP2.asm - ULP5.asm apply here as well.
  2.  
  3.  
  4.     .global    @__UseLibP6
  5.     .text
  6.     .sdreg    r2
  7.     .global    _UseLibP6
  8.     .align    4
  9. _UseLibP6:
  10.     mflr    r11
  11.     stw    r11,8(r1)    #Save return address
  12.     stwu    r1,-96(r1)      #Save stack pointer
  13.     fmr    f16,f1        #Transfer yrel from f1 to f16
  14.     lwz    r24,_MaxCnt(r2)        #MaxCnt in r24.
  15.     lwz    r25,_LPixelBuf(r2)    #Get Location of LPixelBuf
  16.     lwz    r27,_ColorTable32(r2)    #Start of color table
  17.     lwz    r28,_BPP(r2)             #Number bytes per pixel
  18.     lfd    f25,_Factor(r2)    #Get Factor into f25
  19.     lfd    f22,_Two(r2)    #Get Two into f22 as constant
  20.     lfd    f23,_Limit(r2)    #Get Limit into f23 as constant
  21.     fadd    f14,f22,f22    #f14 is 4.
  22.     fadd    f14,f14,f22    #f14 is 6.
  23.     fdiv    f14,f14,f22    #f14 is 3.
  24.  
  25. #    f14 is 3.0
  26.  
  27. #    Use f27 as intermediate value in calculation of Zr4.
  28.  
  29. #The above could have been done with a global definition of 3.000.
  30.  
  31.     li    r30,0        #xtemp = 0.
  32.     fsub    f15,f22,f22    #(float)xtemp = 0.
  33.     lfd    f10,_XCenter(r2)#f10 = XCenter
  34.     fsub    f15,f15,f10    #xRel = xRel - XCenter
  35.     fdiv    f18,f15,f25    #xRel = xRel/Factor
  36.  
  37.     lfd    f21,_DX(r2)    #Get the real value of Delta x.
  38.     lwz    r29,_RightEdge(r2)
  39.  
  40. Start:
  41.     fmr    f15,f18        #Initial value of Zr is xRel
  42.  
  43. #  The following line was moved before rather than after fmr f17,f16
  44. #  to give the fpu a break.
  45.     li    r23,1        #Initialize CurCnt = 1
  46.     fmr    f17,f16        #yRel into f17 as initial Zi.
  47.     b    l3        #Check to see if to MaxCnt
  48. l2:
  49.     fmul    f24,f15,f15    #Zr2 in f24
  50.     fmul    f4,f17,f17    #Zi2 = Zi*Zi
  51.     fadd    f19,f24,f4      #Zr2 + Zi2 -> f19
  52.     fcmpu    cr0,f19,f23    #Compare with Limit in f23.
  53.     ble    cr0,l6
  54.  
  55. #The following section is not very time-critical as it is only reached once.
  56. #for each pixel
  57.     cmpwi    cr0,r28,2    #See if BPP < 2
  58.     blt    cr0,l8
  59. l7:
  60.     slwi    r10,r23,2    #4 times CurCnt for offset in ColorTable32
  61.     add    r26,r27,r10    #Find location of pixel color in ColorTable32
  62.     lwz    r11,0(r26)    #Get ARGB from ColorTable
  63.     stw    r11,0(r25)    #Store color in LPixelBuf
  64.     addi    r25,r25,4    #Point to next location in LPixelBuf
  65.     b    l1
  66. l8:    andi.    r3,r23,65535    #Prep Color as UWORD into r3 for PlotIt
  67.     bl    _PlotIt
  68. l9:    b    l1
  69. l6:
  70.     fmul    f20,f4,f14    #Zi2*3 -> f20
  71.      fmul    f27,f24,f14    #3*Zr2 -> f27
  72.     fsub    f20,f24,f20    #Zr2 - 3*Zi2 -> f20
  73.     fsub    f27,f27,f4    #(3Zr2 - Zi2) -> f27
  74.     fmul    f20,f20,f15    #Zr*(Zr2 - 3Zi2) -> f20 = Zr3
  75.  
  76.     fmul    f27,f27,f17    #Zi*(3Zr2 - Zi2) -> f27 = Zi3
  77.  
  78.     fmul    f28,f27,f27    #Zi3*Zi3
  79.     fmul    f29,f20,f20    #Zr3*Zr3
  80.     fmul    f30,f20,f27    #Zr3*Zi3
  81. ##
  82.     fsub    f29,f29,f28    #Zr3*Zr3 - Zi3*Zi3 = Zr6
  83.     fmul    f17,f30,f22    #2*Zr3*Zi3 = Zi
  84.  
  85. #    fmr    f24,f29
  86.  
  87.     fadd    f15,f18,f29     #New Zr = xRel + Zr2
  88. #    fadd    f15,f18,f29
  89.     addi    r23,r23,1       #Increment CurCnt
  90.     fadd    f17,f16,f17    #Zi = Zi + yRel
  91.  
  92. l3:
  93.     cmpw    cr0,r23,r24    #See if CurCnt < MaxCnt
  94.     blt    cr0,l2        #Repeat until MaxCnt reached
  95.  
  96.     cmpwi    cr0,r28,2    #See if BPP < 2
  97.     blt    cr0,l11
  98. l10:
  99.  
  100.     lis    r12,4
  101.     addi    r12,r12,-4
  102.     add    r26,r27,r12    #Find location of pixel color
  103.     lwz    r11,0(r26)      #Get color
  104.  
  105.     stw    r11,0(r25)    #Store color in LPixelBuf
  106.     addi    r25,r25,4    #Point to next pixel in buffer
  107.     b    l1        #Was l12
  108. l11:
  109.     lis    r11,1
  110.     addi    r3,r11,-1    #ffff into r3 for PlotIt
  111.     bl    _PlotIt
  112. l1:
  113.     fadd    f18,f18,f21    #Find new value of xRel (xRel = xRel + DX).
  114.     addi    r30,r30,1    #Increment xtemp.
  115.     cmpw    cr0,r30,r29    #See if to RightEdge
  116.  
  117.     blt    cr0,Start    #Repeat until row is done.
  118.     stw    r25,_LPixelBuf(r2)  #New location in long pixel buffer
  119.     addi    r1,r1,96        #Balance Stack pointer
  120.     lwz    r11,8(r1)    #Get return address
  121.     mtlr    r11
  122.     fmr    f1,f20
  123.  
  124.     blr
  125.     .type    _UseLibP6,@function
  126.     .size    _UseLibP6,$-_UseLibP6
  127.  
  128.     .global    _MaxCnt
  129.     .global    _RightEdge
  130.     .global    _XCenter
  131.     .global    _Factor
  132.     .global    _Limit
  133.     .global    _Two
  134.     .global    _LPixelBuf
  135.     .global    _ColorTable32
  136.     .global    _BPP
  137.     .global    _DX
  138.     .global    _PlotIt
  139.     .global    @__PlotIt
  140.  
  141.